﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;

namespace ZombieMonkeys.Vibria.Logic
{
    /// <summary>
    /// The main component of the sudoku puzzle
    /// </summary>
    public class Square
    {
        //how do we really want note to work?
        string note;

        int value; //this could also be a char, instead of int

        public int Value
        {
            get { return value; }
            
        }
       // MiniGrid miniGrid = new MiniGrid(row, col);

        //public MiniGrid MiniGrid
        //{
        //    get { return miniGrid; }
            
        //}

        //this will be a string representation of the squares value
        string text;

        bool permanent;

        bool penMode;

        int row;

        int col;

        int miniGrid;

        Point point;

        public Point Point
        {
            get 
            {
                point = new Point(row, col);
                return point; 
            }
            set { point = new Point(row, col); }
        }
 
        /// <summary>
        /// Default constructor
        /// </summary>
        public Square()
        {
            
            value = 0;
        }

        /// <summary>
        /// Method to change to stored value of a square
        /// </summary>
        /// <param name="newValue">the value to assign</param>
        public void SetValue(int ? newValue)
        {
            //made a few changes here so that i can set the squares to string .empty if i pass a 0 value to them
            string newText = String.Empty;

            //get the text value from the value passed in
            value = 0;

            if (newValue.HasValue)
            {
                value = newValue.Value;
                //set to string.empty
                newText = value.ToString();
            }
            setText(newText);
        }
        
        public void SetPoint()
        {
            point = new Point(row, col);
        }

        public string GetValue()
        {
            return value.ToString();
        }

        //if we are going to have this we need to decide this soon so we can design it in or out
        //this is if we want to design our sudoku to handle more than just numbers
        public void setPicture(string picFile)
        {
            setPic(picFile);
        }

        /// <summary>
        /// the ability to set a picture for a sudoku square
        /// </summary>
        /// <param name="pic">the file that represents the graphic</param>
        private void setPic(string pic)
        { 
        
        }

        private void setText(string numberText)
        {
            text = numberText;
        }

        /// <summary>
        /// Set the row that a square belongs to
        /// </summary>
        /// <param name="gridRow">the squares row</param>
        public void SetRow(int gridRow)
        {
            
            row = gridRow;
           // miniGrid.Row = row;
        }

        /// <summary>
        /// Gets the row for the UI to use
        /// </summary>
        /// <returns>row number</returns>
        public int GetRow()
        {
            return row;
        }

        /// <summary>
        /// Set the Column that a square belongs to
        /// </summary>
        /// <param name="gridColumn">the squares column</param>
        public void SetColumn(int gridColumn)
        {
            col = gridColumn;
           // miniGrid.Col = col;
        }

        /// <summary>
        /// Gets the column number for the UI
        /// </summary>
        /// <returns>column number</returns>
        public int GetColumn()
        {
            return col;
        }

        /// <summary>
        /// Set the minigrid that a square belongs to
        /// </summary>
        /// <param name="g"></param>
        public void SetGrid(int g)
        {
            miniGrid = g;
        }

        /// <summary>
        /// Gets the grid number for the UI
        /// </summary>
        /// <returns>minigrid number</returns>
        public int GetGrid()
        {
            return miniGrid;
        }
        
        //for now we can just set the note function as a string primarily for use by the solver
        //When we have time, we can add the functionality to use it in the GUI
        public string Note
        {
            get
            {
                return note;
            }
            set
            {
                note = value;
            }
        }

        /// <summary>
        /// Clears out the value in the current square
        /// </summary>
        public void Clear()
        {
            text = "";
        }
    }
}
